package com.zhengxin.web;

import java.util.List;

import com.zhengxin.pojo.Customer;
import com.zhengxin.pojo.Employee;
import com.zhengxin.pojo.TraceHistory;
import com.zhengxin.utils.UserContext;

public class TraceHistoryAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 封装客户信息
	 * @return
	 */
	private Customer customer;
	
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	
	private TraceHistory traceHistory;

	public TraceHistory getTraceHistory() {
		return traceHistory;
	}

	public void setTraceHistory(TraceHistory traceHistory) {
		this.traceHistory = traceHistory;
	}
	
	

	//添加页面的跳转
	public String viewEdit(){
//		//查询所有的营销人员 (跟进的客户，在jsp页面从session获取，就是当前登陆用户)
//		List<Employee> listEmp=employeeService.getAll();
//		request.put("listEmp", listEmp);
		if(customer != null){
			customer=customerService.findByid(customer.getId());
		}		
		return "edit";
	}
	
	//列表展示方法
	public String list(){
		List<TraceHistory> listTrace=traceHistoryService.getAll();
		request.put("listTrace", listTrace);
		return "list";
	}
	
	//保存
	public String save(){
		//封装客户资料
		traceHistory.setCustomer(customer);
		//封装营销人员的信息
		Employee employee=UserContext.get();
		traceHistory.setEmployee(employee);
		//报存跟进的记录
		traceHistoryService.save(traceHistory);
		return "save";
	}
	
}
